package com.example.kaiya;

import java.io.FileReader;
import java.io.IOException;
import java.io.InputStream;

import com.example.kaiya.R;

import android.net.Uri;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.content.res.AssetManager;
import android.util.Log;
import android.view.Gravity;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.ListView;
import android.widget.TextView;
import android.view.View;

public class MainActivity extends Activity implements M{

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.sub_menu);
		ListView menuList = (ListView) findViewById(R.id.ListView_Menu);
		
		final String[] menu_show = m.menuShow();
		ArrayAdapter<String> adapt =
				new ArrayAdapter<String>(this, R.layout.menu_item, menu_show);
		menuList.setAdapter(adapt);
		
		menuList.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            public void onItemClick(AdapterView<?> parent, View itemClicked, int position, long id) {
                // Note: if the list was built "by hand" the id could be used.
                // As-is, though, each item has the same id
                TextView textView = (TextView) itemClicked;
                String strText = textView.getText().toString();
                
                for(int j = 0; j < menu_show.length; j++){
                	if (strText.equalsIgnoreCase(menu_show[j])) {
                		m.picket=j;
                        // Launch the Game Activity
                        startActivity(new Intent(MainActivity.this, SubActivity.class));
                    }
                }
            }
        });
		/*
		Button.OnClickListener mClickListener = new View.OnClickListener()
	    {
	      public void onClick(View v)
	      {
	           switch (v.getId())
	           {
	           case R.id.call:
	        	   startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:" +  ctemp.getTPNum())));
	                break;
	           case R.id.pageLink:
	        	   startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(ctemp.getHyper())));
	                break;
	           }
	      }
	    };
	    
		findViewById(R.id.call).setOnClickListener(mClickListener);
        findViewById(R.id.pageLink).setOnClickListener(mClickListener);*/
	}

	
	/*
	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		super.onCreateOptionsMenu(menu);
		getMenuInflater().inflate(R.menu.main, menu);
		return true;
	}*/
	/*
	@Override
	public boolean onOptionsItemSelected(MenuItem item) {
		// TODO Auto-generated method stub
		return super.onOptionsItemSelected(item);
	}*/


}